#include "stylesetwidget.h"
#include <QTreeWidgetItem>
#include <QHeaderView>
#include <QComboBox>
#include <QLineEdit>

StyleSetWidget::StyleSetWidget(QWidget *parent) : QTreeWidget(parent)
{
//    setMaximumSize((Screen::GetScreenWidth())>>1, (Screen::GetScreenHeight()));
    setMinimumSize((Screen::GetScreenWidth())>>5, (Screen::GetScreenHeight()));
    setAlternatingRowColors(true);
    setPalette(QPalette(QColor(210, 210, 210)));

    setColumnCount(2);
    setHeaderLabels(QStringList()<<tr("样式设置")<<tr("值"));//设置标题
    headerItem()->setHidden(true);
    header()->setSectionResizeMode(QHeaderView::ResizeToContents);

    m_common_style_data.clear();
    m_curr_style_data.clear();
    m_pass_style_data.clear();
    m_future_style_data.clear();

    m_info = NULL;
    m_url = "";
    m_style = "";
    m_prefix = "";
    m_suffix = "";

    m_com_animation = NULL;
    m_edit_place_way = NULL;
    m_edit_qss1 = NULL;
    m_edit_qss2 = NULL;
    m_edit_format = NULL;

    m_curr_com_animation = NULL;
    m_curr_edit_place_way = NULL;
    m_curr_edit_qss1 = NULL;
    m_curr_edit_qss2 = NULL;
    m_curr_edit_format = NULL;

    m_pass_com_animation = NULL;
    m_pass_edit_place_way = NULL;
    m_pass_edit_qss1 = NULL;
    m_pass_edit_qss2 = NULL;
    m_pass_edit_format = NULL;

    m_future_com_animation = NULL;
    m_future_edit_place_way = NULL;
    m_future_edit_qss1 = NULL;
    m_future_edit_qss2 = NULL;
    m_future_edit_format = NULL;
}

StyleSetWidget::~StyleSetWidget()
{

}

void StyleSetWidget::SetMapData(QMap<QString, QString> &map, QSettings &settings)
{
    map["qss1"] = settings.value("qss1", "").toString();
    map["qss2"] = settings.value("qss2", "").toString();
    map["format"] = settings.value("format", "").toString();
    map["place_way"] = settings.value("place_way", "PH").toString();
    map["animation"] = settings.value("animation", "none").toString();
}

void StyleSetWidget::GetStyleData(QString style)
{
    m_common_style_data.clear();
    m_curr_style_data.clear();
    m_pass_style_data.clear();
    m_future_style_data.clear();

    if (style == "")
        return;

    QString filename = m_prefix + QString(StyleConfigFile);
    QFileInfo fileInfo(filename);
    if (!fileInfo.isFile())
        return;

    QSettings settings(filename, QSettings::IniFormat);
    settings.setIniCodec(QTextCodec::codecForName("utf-8"));

    if (style.contains("current") || style.contains("pass") || style.contains("future"))
    {
        QStringList list = style.split("_");
        QString style_curr = QString("%1_%2_current").arg(list.at(0)).arg(list.at(1));
        QString style_pass = QString("%1_%2_pass").arg(list.at(0)).arg(list.at(1));
        QString style_future = QString("%1_%2_future").arg(list.at(0)).arg(list.at(1));

        settings.beginGroup(style_future);
        SetMapData(m_future_style_data, settings);
        settings.endGroup();

        settings.beginGroup(style_pass);
        SetMapData(m_pass_style_data, settings);
        settings.endGroup();

        settings.beginGroup(style_curr);
        SetMapData(m_curr_style_data, settings);
        settings.endGroup();
    } else
    {
        settings.beginGroup(style);
        SetMapData(m_common_style_data, settings);
        settings.endGroup();
    }
}

void StyleSetWidget::StyleWidgetSetData(ViewObjectInfo *info)
{
    headerItem()->setHidden(true);
    clear();

    m_url = info->object->GetFinalUrl();

    m_suffix = m_url.right(3);

    if (m_suffix == "hqv" || m_suffix == "gif")
        return;

    //目前只支持StationView SingleView NextView StartView NowView TerminalView ArriveView
    const QStringList obj_list = {"StationView", "SingleView", "NextView", "StartView", "NowView", "TerminalView", "ArriveView"};
    m_object_name = info->object->GetObjectParam()->GetObjectName();
    if (!obj_list.contains(m_object_name))
        return;

    m_prefix = info->object->GetPrefix();
    m_filename = info->object->GetFilename();
    m_name = info->object->GetObjectParam()->GetName();
    m_info = info;

    if (m_url.contains("##"))
    {
        QStringList list = m_url.split("##");
        m_style = list.at(0);
    } else
    {
        QString filename_without_xml = m_filename.left(m_filename.size() - 4);
        QStringList list = filename_without_xml.split("_");
        QString ui_type = list.at(ParamType);

        //若没有样式名称，需要根据规则给一个样式名称，以便编辑之后存储
        if (m_object_name == "StationView")
        {
            m_style = QString("%1_station_future").arg(ui_type);
        }
        else if (m_object_name == "SingleView")  //SingleView的name就是他的样式
        {
            m_style = QString("%1_%2").arg(ui_type).arg(m_name);
        }
        else if (m_object_name == "ArriveView")
        {
            m_style = QString("arrive_station");
        }
        else
        {
            m_style = QString("%1_%2_station").arg(ui_type).arg(m_object_name.toLower().left(m_object_name.size() - 4));
        }
    }

    GetStyleData(m_style);

    if (m_object_name == "StationView")
        StationViewStyleSet();
    else
        CommonViewStyleSet();
}

void StyleSetWidget::ShowDataAndRecord(QMap<QString, QString> &map)
{
    if (m_style == "" || m_prefix == "")
        return;

    QString filename = m_prefix + QString(StyleConfigFile);
    QFileInfo fileInfo(filename);
    if (!fileInfo.isFile())
        return;

    QSettings settings(filename, QSettings::IniFormat);
    settings.setIniCodec(QTextCodec::codecForName("utf-8"));

    //此处找不到组的时候需要直接写入
    settings.beginGroup(m_style);
    settings.setValue("animation", map["animation"]);
    settings.setValue("place_way", map["place_way"]);
    settings.setValue("qss1", map["qss1"]);
    settings.setValue("qss2", map["qss2"]);
    settings.setValue("format", map["format"]);
    settings.endGroup();

    LOG_QDEBUG << QString("record style: style=%1  url=%2").arg(m_style).arg(m_url);
    LOG_QDEBUG << map;

    m_info->object->FinalShow(m_url);
}

void StyleSetWidget::DeleteStyleGroup()
{
    if (m_style == "" || m_prefix == "")
        return;

    LOG_QDEBUG << QString("delete item and style: style=%1  url=%2").arg(m_style).arg(m_url);

    QString filename = m_prefix + QString(StyleConfigFile);
    QFileInfo fileInfo(filename);
    if (!fileInfo.isFile())
        return;

    QSettings settings(filename, QSettings::IniFormat);
    settings.setIniCodec(QTextCodec::codecForName("utf-8"));

    settings.remove(m_style);
}

//comm
void StyleSetWidget::CommonAnimationChanged(QString text)
{
    m_common_style_data["animation"] = text;
    ShowDataAndRecord(m_common_style_data);
}
void StyleSetWidget::CommonPlaceWayEditFinished()
{
    m_common_style_data["place_way"] = m_edit_place_way->text();
    ShowDataAndRecord(m_common_style_data);
}
void StyleSetWidget::CommonQss1EditFinished()
{
    m_common_style_data["qss1"] = m_edit_qss1->text();
    ShowDataAndRecord(m_common_style_data);
}
void StyleSetWidget::CommonQss2EditFinished()
{
    m_common_style_data["qss2"] = m_edit_qss2->text();
    ShowDataAndRecord(m_common_style_data);
}
void StyleSetWidget::CommonFormatEditFinished()
{
    m_common_style_data["format"] = m_edit_format->text();
    ShowDataAndRecord(m_common_style_data);
}

//curr
void StyleSetWidget::CurrAnimationChanged(QString text)
{
    m_curr_style_data["animation"] = text;
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_current").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_curr_style_data);
}
void StyleSetWidget::CurrPlaceWayEditFinished()
{
    m_curr_style_data["place_way"] = m_curr_edit_place_way->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_current").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_curr_style_data);
}
void StyleSetWidget::CurrQss1EditFinished()
{
    m_curr_style_data["qss1"] = m_curr_edit_qss1->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_current").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_curr_style_data);
}
void StyleSetWidget::CurrQss2EditFinished()
{
    m_curr_style_data["qss2"] = m_curr_edit_qss2->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_current").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_curr_style_data);
}
void StyleSetWidget::CurrFormatEditFinished()
{
    m_curr_style_data["format"] = m_curr_edit_format->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_current").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_curr_style_data);
}

//future
void StyleSetWidget::FutureAnimationChanged(QString text)
{
    m_future_style_data["animation"] = text;
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_future").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_future_style_data);
}
void StyleSetWidget::FuturePlaceWayEditFinished()
{
    m_future_style_data["place_way"] = m_future_edit_place_way->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_future").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_future_style_data);
}
void StyleSetWidget::FutureQss1EditFinished()
{
    m_future_style_data["qss1"] = m_future_edit_qss1->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_future").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_future_style_data);
}
void StyleSetWidget::FutureQss2EditFinished()
{
    m_future_style_data["qss2"] = m_future_edit_qss2->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_future").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_future_style_data);
}
void StyleSetWidget::FutureFormatEditFinished()
{
    m_future_style_data["format"] = m_future_edit_format->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_future").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_future_style_data);
}

//pass
void StyleSetWidget::PassAnimationChanged(QString text)
{
    m_pass_style_data["animation"] = text;
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_pass").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_pass_style_data);
}
void StyleSetWidget::PassPlaceWayEditFinished()
{
    m_pass_style_data["place_way"] = m_pass_edit_place_way->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_pass").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_pass_style_data);
}
void StyleSetWidget::PassQss1EditFinished()
{
    m_pass_style_data["qss1"] = m_pass_edit_qss1->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_pass").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_pass_style_data);
}
void StyleSetWidget::PassQss2EditFinished()
{
    m_pass_style_data["qss2"] = m_pass_edit_qss2->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_pass").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_pass_style_data);
}
void StyleSetWidget::PassFormatEditFinished()
{
    m_pass_style_data["format"] = m_pass_edit_format->text();
    QStringList list = m_style.split("_");
    m_style = QString("%1_%2_pass").arg(list.at(0)).arg(list.at(1));
    ShowDataAndRecord(m_pass_style_data);
}

void StyleSetWidget::CommonViewStyleSet()
{
    headerItem()->setHidden(false);
    clear();

    if (m_suffix != "png")
    {
        QTreeWidgetItem *place_way = new QTreeWidgetItem;
        place_way->setToolTip(0, tr("PH:横向;PV:纵向;P45:45度"));
        place_way->setText(0, tr("place_way"));

        QTreeWidgetItem *qss1 = new QTreeWidgetItem;
        qss1->setText(0, tr("qss1"));

        QTreeWidgetItem *qss2 = new QTreeWidgetItem;
        qss2->setText(0, tr("qss2"));

        QTreeWidgetItem *format = new QTreeWidgetItem;
        format->setToolTip(0, tr("如:下一站:%1 Next Station:%2;"));
        format->setText(0, tr("format"));

        insertTopLevelItem(0, format);
        insertTopLevelItem(0, qss2);
        insertTopLevelItem(0, qss1);
        insertTopLevelItem(0, place_way);

        m_edit_place_way = new QLineEdit;
        setItemWidget(place_way, 1, m_edit_place_way);
        m_edit_place_way->setText(m_common_style_data["place_way"]);
        connect(m_edit_place_way, &QLineEdit::editingFinished, this, &StyleSetWidget::CommonPlaceWayEditFinished);

        m_edit_qss1 = new QLineEdit;
        setItemWidget(qss1, 1, m_edit_qss1);
        m_edit_qss1->setText(m_common_style_data["qss1"]);
        connect(m_edit_qss1, &QLineEdit::editingFinished, this, &StyleSetWidget::CommonQss1EditFinished);

        m_edit_qss2 = new QLineEdit;
        setItemWidget(qss2, 1, m_edit_qss2);
        m_edit_qss2->setText(m_common_style_data["qss2"]);
        connect(m_edit_qss2, &QLineEdit::editingFinished, this, &StyleSetWidget::CommonQss2EditFinished);

        m_edit_format = new QLineEdit;
        setItemWidget(format, 1, m_edit_format);
        m_edit_format->setText(m_common_style_data["format"]);
        connect(m_edit_format, &QLineEdit::editingFinished, this, &StyleSetWidget::CommonFormatEditFinished);

        m_edit_qss1->setStyleSheet(m_edit_qss);
        m_edit_qss2->setStyleSheet(m_edit_qss);
        m_edit_format->setStyleSheet(m_edit_qss);
    }

    QTreeWidgetItem *animation = new QTreeWidgetItem;
    animation->setText(0, tr("animation"));
    animation->setToolTip(0, tr("None:无动画;\nLeftRight:左右移动;\nOpacityEffect:若隐若现;\nScale:平滑放大缩小;\nTwoFrameScale:两帧放大缩小;"));
    insertTopLevelItem(0, animation);
    QComboBox *com_animation = new QComboBox;
    com_animation->insertItems(0, m_animation_text);
    SetAnimationComboBoxData(m_common_style_data, com_animation);
    setItemWidget(animation, 1, com_animation);
    connect(com_animation, &QComboBox::currentTextChanged, this, &StyleSetWidget::CommonAnimationChanged);
}

void StyleSetWidget::SetAnimationComboBoxData(QMap<QString, QString> map, QComboBox *box)
{
    box->setCurrentIndex(0);
    if (map["animation"] == "LeftRight")
        box->setCurrentIndex(1);
    else if (map["animation"] == "OpacityEffect")
        box->setCurrentIndex(2);
    else if (map["animation"] == "Scale")
        box->setCurrentIndex(3);
    else if (map["animation"] == "TwoFrameScale")
        box->setCurrentIndex(4);
}

void StyleSetWidget::StationViewStyleSet()
{
    headerItem()->setHidden(false);
    clear();

    QTreeWidgetItem *curr = new QTreeWidgetItem;
    curr->setText(0, tr("current"));
    insertTopLevelItem(0, curr);

    QTreeWidgetItem *pass = new QTreeWidgetItem;
    pass->setText(0, tr("pass"));
    insertTopLevelItem(0, pass);

    QTreeWidgetItem *future = new QTreeWidgetItem;
    future->setText(0, tr("future"));
    insertTopLevelItem(0, future);

    curr->setExpanded(true);
    pass->setExpanded(true);
    future->setExpanded(true);

    QTreeWidgetItem *curr_animation = new QTreeWidgetItem;
    curr_animation->setToolTip(0, tr("None:无动画;\nLeftRight:左右移动;\nOpacityEffect:若隐若现;\nScale:平滑放大缩小;\nTwoFrameScale:两帧放大缩小;"));
    curr_animation->setText(0, tr("animation"));
    QTreeWidgetItem *pass_animation = new QTreeWidgetItem;
    pass_animation->setToolTip(0, tr("None:无动画;\nLeftRight:左右移动;\nOpacityEffect:若隐若现;\nScale:平滑放大缩小;\nTwoFrameScale:两帧放大缩小;"));
    pass_animation->setText(0, tr("animation"));
    QTreeWidgetItem *future_animation = new QTreeWidgetItem;
    future_animation->setToolTip(0, tr("None:无动画;\nLeftRight:左右移动;\nOpacityEffect:若隐若现;\nScale:平滑放大缩小;\nTwoFrameScale:两帧放大缩小;"));
    future_animation->setText(0, tr("animation"));
    curr->addChild(curr_animation);
    pass->addChild(pass_animation);
    future->addChild(future_animation);

    m_curr_com_animation = new QComboBox;
    m_curr_com_animation->insertItems(0, m_animation_text);
    SetAnimationComboBoxData(m_curr_style_data, m_curr_com_animation);
    setItemWidget(curr_animation, 1, m_curr_com_animation);
    connect(m_curr_com_animation, &QComboBox::currentTextChanged, this, &StyleSetWidget::CurrAnimationChanged);

    m_pass_com_animation = new QComboBox;
    m_pass_com_animation->insertItems(0, m_animation_text);
    SetAnimationComboBoxData(m_pass_style_data, m_pass_com_animation);
    setItemWidget(pass_animation, 1, m_pass_com_animation);
    connect(m_pass_com_animation, &QComboBox::currentTextChanged, this, &StyleSetWidget::PassAnimationChanged);

    m_future_com_animation = new QComboBox;
    m_future_com_animation->insertItems(0, m_animation_text);
    SetAnimationComboBoxData(m_future_style_data, m_future_com_animation);
    setItemWidget(future_animation, 1, m_future_com_animation);
    connect(m_future_com_animation, &QComboBox::currentTextChanged, this, &StyleSetWidget::FutureAnimationChanged);

    if (m_suffix != "png")
    {
        QTreeWidgetItem *curr_place_way = new QTreeWidgetItem;
        curr_place_way->setToolTip(0, tr("PH:横向;\nPV:纵向;\nP45:45度;"));
        curr_place_way->setText(0, tr("place_way"));
        QTreeWidgetItem *curr_qss1 = new QTreeWidgetItem;
        curr_qss1->setText(0, tr("qss1"));
        QTreeWidgetItem *curr_qss2 = new QTreeWidgetItem;
        curr_qss2->setText(0, tr("qss2"));
        QTreeWidgetItem *curr_format = new QTreeWidgetItem;
        curr_format->setToolTip(0, tr("如:下一站:%1 Next Station:%2;"));
        curr_format->setText(0, tr("format"));

        QTreeWidgetItem *pass_place_way = new QTreeWidgetItem;
        pass_place_way->setToolTip(0, tr("PH:横向;\nPV:纵向;\nP45:45度;"));
        pass_place_way->setText(0, tr("place_way"));
        QTreeWidgetItem *pass_qss1 = new QTreeWidgetItem;
        pass_qss1->setText(0, tr("qss1"));
        QTreeWidgetItem *pass_qss2 = new QTreeWidgetItem;
        pass_qss2->setText(0, tr("qss2"));
        QTreeWidgetItem *pass_format = new QTreeWidgetItem;
        pass_format->setToolTip(0, tr("如:下一站:%1 Next Station:%2;"));
        pass_format->setText(0, tr("format"));

        QTreeWidgetItem *future_place_way = new QTreeWidgetItem;
        future_place_way->setToolTip(0, tr("PH:横向;\nPV:纵向;\nP45:45度;"));
        future_place_way->setText(0, tr("place_way"));
        QTreeWidgetItem *future_qss1 = new QTreeWidgetItem;
        future_qss1->setText(0, tr("qss1"));
        QTreeWidgetItem *future_qss2 = new QTreeWidgetItem;
        future_qss2->setText(0, tr("qss2"));
        QTreeWidgetItem *future_format = new QTreeWidgetItem;
        future_format->setToolTip(0, tr("如:下一站:%1 Next Station:%2;"));
        future_format->setText(0, tr("format"));

        curr->addChild(curr_place_way);
        curr->addChild(curr_qss1);
        curr->addChild(curr_qss2);
        curr->addChild(curr_format);

        pass->addChild(pass_place_way);
        pass->addChild(pass_qss1);
        pass->addChild(pass_qss2);
        pass->addChild(pass_format);

        future->addChild(future_place_way);
        future->addChild(future_qss1);
        future->addChild(future_qss2);
        future->addChild(future_format);

        m_curr_edit_place_way = new QLineEdit;
        m_curr_edit_place_way->setText(m_curr_style_data["place_way"]);
        connect(m_curr_edit_place_way, &QLineEdit::editingFinished, this, &StyleSetWidget::CurrPlaceWayEditFinished);
        setItemWidget(curr_place_way, 1, m_curr_edit_place_way);

        m_pass_edit_place_way = new QLineEdit;
        m_pass_edit_place_way->setText(m_pass_style_data["place_way"]);
        connect(m_pass_edit_place_way, &QLineEdit::editingFinished, this, &StyleSetWidget::PassPlaceWayEditFinished);
        setItemWidget(pass_place_way, 1, m_pass_edit_place_way);

        m_future_edit_place_way = new QLineEdit;
        m_future_edit_place_way->setText(m_future_style_data["place_way"]);
        connect(m_future_edit_place_way, &QLineEdit::editingFinished, this, &StyleSetWidget::FuturePlaceWayEditFinished);
        setItemWidget(future_place_way, 1, m_future_edit_place_way);

        m_curr_edit_qss1 = new QLineEdit;
        m_curr_edit_qss1->setText(m_curr_style_data["qss1"]);
        connect(m_curr_edit_qss1, &QLineEdit::editingFinished, this, &StyleSetWidget::CurrQss1EditFinished);
        setItemWidget(curr_qss1, 1, m_curr_edit_qss1);
        m_pass_edit_qss1 = new QLineEdit;
        m_pass_edit_qss1->setText(m_pass_style_data["qss1"]);
        connect(m_pass_edit_qss1, &QLineEdit::editingFinished, this, &StyleSetWidget::PassQss1EditFinished);
        setItemWidget(pass_qss1, 1, m_pass_edit_qss1);
        m_future_edit_qss1 = new QLineEdit;
        m_future_edit_qss1->setText(m_future_style_data["qss1"]);
        connect(m_future_edit_qss1, &QLineEdit::editingFinished, this, &StyleSetWidget::FutureQss1EditFinished);
        setItemWidget(future_qss1, 1, m_future_edit_qss1);

        m_curr_edit_qss2 = new QLineEdit;
        m_curr_edit_qss2->setText(m_curr_style_data["qss2"]);
        connect(m_curr_edit_qss2, &QLineEdit::editingFinished, this, &StyleSetWidget::CurrQss2EditFinished);
        setItemWidget(curr_qss2, 1, m_curr_edit_qss2);
        m_pass_edit_qss2 = new QLineEdit;
        m_pass_edit_qss2->setText(m_pass_style_data["qss2"]);
        connect(m_pass_edit_qss2, &QLineEdit::editingFinished, this, &StyleSetWidget::PassQss2EditFinished);
        setItemWidget(pass_qss2, 1, m_pass_edit_qss2);
        m_future_edit_qss2 = new QLineEdit;
        m_future_edit_qss2->setText(m_future_style_data["qss2"]);
        connect(m_future_edit_qss2, &QLineEdit::editingFinished, this, &StyleSetWidget::FutureQss2EditFinished);
        setItemWidget(future_qss2, 1, m_future_edit_qss2);

        m_curr_edit_format = new QLineEdit;
        m_curr_edit_format->setText(m_curr_style_data["format"]);
        connect(m_curr_edit_format, &QLineEdit::editingFinished, this, &StyleSetWidget::CurrFormatEditFinished);
        setItemWidget(curr_format, 1, m_curr_edit_format);
        m_pass_edit_format = new QLineEdit;
        m_pass_edit_format->setText(m_pass_style_data["format"]);
        connect(m_pass_edit_format, &QLineEdit::editingFinished, this, &StyleSetWidget::PassFormatEditFinished);
        setItemWidget(pass_format, 1, m_pass_edit_format);
        m_future_edit_format = new QLineEdit;
        m_future_edit_format->setText(m_future_style_data["format"]);
        connect(m_future_edit_format, &QLineEdit::editingFinished, this, &StyleSetWidget::FutureFormatEditFinished);
        setItemWidget(future_format, 1, m_future_edit_format);

        m_curr_edit_qss1->setStyleSheet(m_edit_qss);
        m_curr_edit_qss2->setStyleSheet(m_edit_qss);
        m_curr_edit_format->setStyleSheet(m_edit_qss);

        m_future_edit_qss1->setStyleSheet(m_edit_qss);
        m_future_edit_qss2->setStyleSheet(m_edit_qss);
        m_future_edit_format->setStyleSheet(m_edit_qss);

        m_pass_edit_qss1->setStyleSheet(m_edit_qss);
        m_pass_edit_qss2->setStyleSheet(m_edit_qss);
        m_pass_edit_format->setStyleSheet(m_edit_qss);
    }
}
